package cn.edu.whu.MVCByHand.controller;

import cn.edu.whu.MVCByHand.annotation.MyAutowired;
import cn.edu.whu.MVCByHand.annotation.MyController;
import cn.edu.whu.MVCByHand.annotation.MyRequestMapping;
import cn.edu.whu.MVCByHand.annotation.MyRequestParam;
import cn.edu.whu.MVCByHand.service.TestService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@MyController
@MyRequestMapping("test2")
public class DemoController {
	@MyAutowired
	private TestService testService;

	@MyRequestMapping("test3")
	public void myTest(HttpServletRequest request, HttpServletResponse response,
	                   @MyRequestParam("param") String param){
		try {
			response.getWriter().write( "Test2Controller:the param you send is :"+param);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	@MyRequestMapping("test4")
	public void myTest1(HttpServletRequest request, HttpServletResponse response,
	                   @MyRequestParam("param") String param){
		try {
			testService.printParam(param);
			response.getWriter().write( "Test2Controller:the param you send is :"+param);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
